import { Controller, Post, Body, Get, Query, UseGuards } from '@nestjs/common';
import { UserService } from './user.service';
import { CreateUserDto } from './dto/create-user.dto';
import { LoginUserDto } from './dto/login-user.dto';
import { LoginGuard } from 'src/login.guard';

@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Post('register')
  create(@Body() createUserDto: CreateUserDto) {
    return this.userService.create(createUserDto);
  }

  @Post('login')
  login(@Body() loginUserDto: LoginUserDto) {
    return this.userService.login(loginUserDto);
  }

  @Get('refresh')
  refresh(@Query('refreshToken') refreshToken: string) {
    return this.userService.refreshToken(refreshToken);
  }

  @Get('info')
  @UseGuards(LoginGuard)
  getUserInfo(@Query('id') id: number) {
    return this.userService.getUserInfo(+id);
  }
}
